#!/bin/bash

OTA_DIR=./
OTA_FILE=ota.tar
APP_FILE=edge.tar
SIG_FILE=signature

key="71776572747975696f706c6b6a686766"
iv="7a786376626e6d6c6b6a686766647361"

if [ -f ${OTA_DIR}/${OTA_FILE} ]; then
        echo "ota ..."
        tar xf ${OTA_DIR}/${OTA_FILE} -C ${OTA_DIR}/
        encrypt_str=$(md5sum ${OTA_DIR}/${APP_FILE}| cut -d ' ' -f1| openssl enc -e -aes-128-cbc -base64 -K ${key} -iv ${iv} -nosalt)
        md5_str=$(cat ${OTA_DIR}/${SIG_FILE})

        echo ${encrypt_str} ${md5_str}
        if [ "$md5_str" == "$encrypt_str" ]; then
                echo "start ota ..."
        fi
else
        echo "start ..."
fi




